﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Practices.EnterpriseLibrary.Data;
using Enterprise.DataFactory;
using Enterprise.Model.BusiTravel;
using Enterprise.Infrastructure;
namespace Enterprise.Data.BusiTravel
{
    /// <summary>
    /// 差旅数据操作
    /// </summary>
    public class BusiTravelData
    {

        /// <summary>
        ///  公文数据列表
        /// </summary>
        /// <returns></returns>
        public List<BusiTravelEntity> BusiTravelList()
        {
            List<BusiTravelEntity> list = new List<BusiTravelEntity>();
            string cmd = "Select * from BUSITRAVEL_INFO";
            IDataReader dr = DbExecute.DataReader(cmd);
            while (dr.Read())
            {
                BusiTravelEntity entity = new BusiTravelEntity();
                if (!Convert.IsDBNull(dr["BID"])) entity.BID = Convert.ToString(dr["BID"]);
                if (!Convert.IsDBNull(dr["DEPTID"])) entity.DEPTID = Convert.ToInt32(dr["DEPTID"]);
                if (!Convert.IsDBNull(dr["USERID"])) entity.USERID = Convert.ToInt32(dr["USERID"]);
                if (!Convert.IsDBNull(dr["BSUBJECT"])) entity.BSUBJECT = Convert.ToString(dr["BSUBJECT"]);
                if (!Convert.IsDBNull(dr["BDESTINATION"])) entity.BDESTINATION = Convert.ToString(dr["BDESTINATION"]);
                if (!Convert.IsDBNull(dr["BLINE"])) entity.BLINE = Convert.ToString(dr["BLINE"]);
                if (!Convert.IsDBNull(dr["BTICKETTYPE"])) entity.BTICKETTYPE = Convert.ToString(dr["BTICKETTYPE"]);
                if (!Convert.IsDBNull(dr["BSTARTIME"])) entity.BSTARTIME = Convert.ToDateTime(dr["BSTARTIME"]);
                if (!Convert.IsDBNull(dr["BENDTIME"])) entity.BENDTIME = Convert.ToDateTime(dr["BENDTIME"]);
                if (!Convert.IsDBNull(dr["BCREATETIME"])) entity.BCREATETIME = Convert.ToDateTime(dr["BCREATETIME"]);
                if (!Convert.IsDBNull(dr["BCHECKERS"])) entity.BCHECKERS = Convert.ToString(dr["BCHECKERS"]);
                if (!Convert.IsDBNull(dr["BSTATE"])) entity.BSTATE = Convert.ToInt32(dr["BSTATE"]);
                if (!Convert.IsDBNull(dr["BCLOSE"])) entity.BCLOSE = Convert.ToInt32(dr["BCLOSE"]);
                if (!Convert.IsDBNull(dr["BCLOSETIME"])) entity.BCLOSETIME = Convert.ToDateTime(dr["BCLOSETIME"]);
                list.Add(entity);
            }
            dr.Close();
            return list;
        }

        /// <summary>
        /// 操作方法
        /// </summary>
        /// <param name="cmd"></param>
        public void Execute(string cmd)
        {
            DbExecute.Execute(cmd);
        }

        /// <summary>
        /// 返回数据集合
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        public DataSet ExcuteDataSet(string cmd)
        {
            return DbExecute.GetDataSet(cmd);
        }

    }
}
